package com.ls.thread.tj;

//共享资源类
public class Threads {
	
	private int number = 0;
	private int shuzi = 1;
	char zimu = 65;
	
	public synchronized boolean zimu() throws InterruptedException{
		
		if(shuzi==1){
			wait();
			return true;
		}
		
		
		System.out.print(zimu);
		zimu++;
		
		System.out.println("字母开头");
		notify();
		//结束条件，及转换线程条件
		if(zimu==91){
		return false;
		}
		wait();
		System.out.println("字母wait后");
		
		return true;
	}
	
	public synchronized boolean shuzi() throws InterruptedException{
		
		if(number == 2){
			System.out.println("数字开头");
			number = 0;
			notify();
			wait();
			System.out.println("数字wait后");
		}
		number++;
		System.out.print(shuzi++);
		
		if(shuzi==53){
			notify();
			return false;
		}
		return true;
	}
}
